﻿#region Opis pliku
//-----------------------------------------------------------------------------
// SmokeParticle.cs
// Autor: Jan Fraś
// 30.10.2012
//-----------------------------------------------------------------------------
#endregion

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace pogra
{
    /// <summary>
    /// dym
    /// </summary>
    class SmokeParticle : Particle
    {
        Vector2 wind = new Vector2(-25f, 0f);
        int tempo = 20;
        public SmokeParticle(Vector2 Position, float Velocity, float rotation, TimeSpan life) :
            base(null, Position, Velocity, rotation, life)
        {
        }

        override public void Draw(ExtendedSpriteBatch exSpriteBatch)
        {
            int size = 6;
            float alpha = (float)(life.TotalMilliseconds / startLife.TotalMilliseconds);
            exSpriteBatch.FillRectangle(new Rectangle((int)(Position.X - size / 2), (int)(Position.Y - size / 2), size, size), Color.White * alpha * 0.05f);
        }

        public override bool Update(TimeSpan deltat)
        {
            Vector2 tmp = new Vector2((float)(Velocity * Math.Cos(rotation)), (float)(Velocity * Math.Sin(rotation)));
            tmp = (tmp * tempo + wind) / (tempo + 1);
            Velocity = tmp.Length();
            rotation = Math.Atan2(tmp.Y, tmp.X) + Rand.nextFloat(-0.2,0.2);
            return base.Update(deltat);
        } 
    }
}
